//*****************************************************************************
// 1. Års eksamen @ Datamatiker - EASJ
// Holmegaard Heldagsskole Administrations system 
// 
// Denne klasse er udarbejdet af: Kasper og Mikkel
//*****************************************************************************
package view.print;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import javax.swing.JPanel;

/**
 *
 * @author Mikkel Bloch
 */
public class Document implements Printable {
    
    private JPanel jpanel;

    public Document(JPanel jpanel) {
        this.jpanel = jpanel;
    }

    
    @Override
    public int print (Graphics g, PageFormat pageFormat, int side) throws PrinterException{
        int printside;
        if (side > 0){
            printside = NO_SUCH_PAGE; 
        }else{
            Graphics2D g2d = (Graphics2D) g;
            double x0 = pageFormat.getImageableX();
            double y0 = pageFormat.getImageableY();
            g2d.translate(x0, y0);
            jpanel.paint(g2d);
            
            printside = PAGE_EXISTS;
        }
        
        return printside;
    }
    
    
}
